import java.io.*;
import java.net.*;
import java.awt.*;
import javax.swing.*;

public class PokkeriKlient extends JApplet implements Runnable{
	BufferedReader br;
	PrintWriter pw;
	JTextArea ta=new JTextArea();
	public static final long serialVersionUID=1;
	public PokkeriKlient(){
		add(new JLabel("Saabuvad andmed"), BorderLayout.NORTH);
		add(new JScrollPane(ta));
		try{
			ta.append("proovib\n");
			Socket sc=new Socket("greeny.cs.tlu.ee", 3000);
			br=new BufferedReader(new InputStreamReader(sc.getInputStream()));
			pw=new PrintWriter(sc.getOutputStream(), true);
			pw.println("kaarel");
			ta.append("avanes\n");
			new Thread(this).start();
		}catch(Exception ex){
			ta.append(ex.getMessage());
		}
	}
	public void run(){
		try{
			String rida=br.readLine();
			while(rida!=null){
				ta.append(rida+"\n");
				rida=br.readLine();
			}
		}catch(Exception ex){
			ta.append(ex.getMessage());
		}
	}
}